/**	
 * ...
 * @author waneck
 */

package asc;

extern class Client implements Dynamic
{
	/**
	 * Read-only; the version and platform of the client.
	 */
	var agent(default, null):String;
	
	/**
	 * Read-only; a string that uniquely identifies the client. 
	 */
	var id(default, null):String;
	
	/**
	 * Read-only; A string containing the IP address of the client.
	 */
	var ip(default, null):String;
	
	/**
	 * Read-only; A string containing the URL of the web page in which the client SWF file is embedded.
	 * If the SWF file isn’t embedded in a web page, the value is the location of the SWF file.
	 */
	var pageUrl(default, null):String;
	
	/**
	 * Read-only; A string indicating the protocol used by the client to connect to the server. This string 
	 * can have one of the following values: rtmp, rtmpt, rtmps, rtmpe, rtpte
	 */
	var protocol(default, null):String;
	
	/**
	 * Read-only; A string containing the URL of the SWF file or the server in which this connection originated.
	 * The property is set when a SWF hosted on a web server or connects to an application on Flash Media Server.
	 * The property is also set when one Flash Media Server connects to another.
	 * 
	 * This property is not set when a SWF from a local file system running in stand-alone Flash Player version 10
	 * or above connects to Flash Media Server. If a SWF file is running in standalone Flash Player version 8 or 9,
	 * the property is set as file:///....
	 */
	var referrer(default, null):String;
	
	/**
	 * Read-only; A boolean value that indicates whether this is an SSL connection (true) or not (false).
	 */
	var secure(default, null):Bool;
	
	/**
	 * Read-only; the URI specified by the client to connect to this application instance. 
	 */
	var uri(default, null):String;
	
	/**
	 * Enables Flash Player to access raw, uncompressed audio data from streams in the specified folders. 
	 * 
	 * @example
	 * // Anyone can gain access to an audio snapshot of the publicdomain/ folder. 
	 * 	  client.audioSampleAccess = "publicdomain"; 
	 */
	var audioSampleAccess:String;
	
	/**
	 * A string of directories containing application resources (shared objects and streams) to which the client
	 * has read access. To give a client read access to directories that contain application resources, list the
	 * directories in a string delimited by semicolons. 
	 * 
	 * For streams, readAccess controls the streams that the connection can play.
	 * For shared objects, readAccess controls whether the connection can listen to shared object changes.
	 */
	var readAccess:String;
	
	/**
	 * Provides write access to directories that contain application resources (such as shared objects and streams)
	 * for this client. To give a client write access to directories that contain application resources, list dire-
	 * ctories in a string delimited by semicolons. By default, all clients have full write access, and the
	 * writeAccess property is set to slash (/). For example, if myMedia is specified as an access level, then
	 * any files or directories in the myMedia directory are also accessible (for example, myMedia/myStreams).
	 * Similarly, any files or subdirectories in the myMedia/myStreams directory are also accessible, and so on.
	 * 
	 * For shared objects, writeAccess provides control over who can create and update the shared objects.
	 * For streams, writeAccess provides control over who can publish and record a stream.
	 * 
	 * You cannot use this property to control access to a single file. To control access to a single file, create a separate directory for the file.
	 * 
	 * Don’t precede the stream path with a leading slash (/) on the client side.
	 */
	var writeAccess:String;
	
	/**
	 * Enables Flash Player to access raw, uncompressed video data from streams in the specified folders.
	 * 
	 * Call the BitmapData.draw() method in client-side ActionScript 3.0 to read the raw data for a stream that is
	 * currently playing. For more information, see the BitmapData.draw() entry in ActionScript 3.0 Language and
	 * Components Reference.
	 */
	var videoSampleAccess:String;
	
	/**
	 * Use this property in conjunction with the Stream.setVirtualPath()  method to map stream URLs to physical
	 * locations on the server. This allows you to serve different content to different versions of Flash Player.
	 * 
	 * When a client connects, it receives a virtual key that corresponds to ranges that you set in the Vhost.xml file.
	 * You can use Client.virtualKey to change that value in a server-side script. The following is the code in the
	 * Vhost.xml file that you must configure:
	 */
	var virtualKey:Dynamic;
	
	/**
	 * xecutes a method in client-side code or on another server. The remote method can return data to the
	 * resultObj  parameter, if provided. Whether the remote agent is a client or another server, the method
	 * is called on the remote agent’s NetConnection object.
	 * 
	 * @param	methodName	A string indicating a remote method. The string uses the form
	 * 				"[objectPath/]method". For example, the string "someObj/doSomething"
	 * 				tells the client to invoke the NetConnection.someObj.doSomething() method
	 * 				on the client or remote server. The string "doAction"  calls the doAction()
	 * 				method on the client or remote server.
	 * 
	 * @param	?resultObj	An Object. This is an optional parameter that is required when
	 * 				the sender expects a return value from the client. If parameters are passed
	 * 				but no return value is desired, pass the value null.
	 * @param	?p1...p7	Optional parameters that can be of any ActionScript type, including
	 * 				a reference to another ActionScript object. 
	 * @return	A boolean value of true if a call to methodName was successful on the client; otherwise, false.
	 */
	function call(methodName:String, ?resultObj:Dynamic, ?p1:Dynamic, ?p2:Dynamic, ?p3:Dynamic, ?p4:Dynamic, ?p5:Dynamic, ?p6:Dynamic, ?p7:Dynamic):Bool;
	
	/**
	 * Call this method from a client-side script to detect client bandwidth. If the client is connected directly
	 * to the origin server, bandwidth detection occurs on the origin. If the client is connected to the origin
	 * server through an edge server, bandwidth detection happens at the first edge to which the client connected.
	 */
	function checkBandwidth():Void;
	
	/**
	 * Returns the maximum bandwidth that the client or the server can use for this connection. Use the iDirection
	 * parameter to get the value for each direction of the connection. The value returned indicates bytes per second
	 * and can be changed with the Client.setBandwidthLimit()  method. Set the default value for a connection in the
	 * Application.xml file of each application.
	 * 
	 * @param	iDirection	A number specifying the connection direction. The value 0 indicates a client-to-server
	 * 				direction; 1 indicates a server-to-client direction. 
	 * @return	bandwidthLimit
	 */
	function getBandwidthLimit(iDirection:Float):Float;
	
	/**
	 * Returns statistics for the client
	 * You can call this method from a client-side script. Call the NetConnection.call() method and pass it the
	 * name of the method, a result object, and any arguments, as in the following:
	 * 
	 * @return	An Object with various properties for each statistic returned.
	 */
	function getStats():Application.StatsProps;
	
	/**
	 * Sends a “ping” message to the client and waits for a response. If the client responds, the method returns
	 * true; otherwise, false. Use this method to determine whether the client connection is still active.
	 * 
	 * @return	true if client is still active
	 */
	function ping():Bool;
	
	/**
	 * You can define methods on the Client object and call the methods from client-side code. To call methods from
	 * client-side code, call the NetConnection.call() method and pass it the name of the method you defined. The
	 * server searches the Client object instance for the method. If the method is found, it is invoked and the return
	 * value is sent back to the result object specified in the call to NetConnection.call().
	 * 
	 * @param	p1, ..., pN		Optional parameters passed to the NetConnection.call()  method.
	 * @see		http://help.adobe.com/en_US/FlashMediaServer/3.5_SS_ASD/WS5b3ccc516d4fbf351e63e3d11a11afc95e-7ec3.html
	 * @return	
	 */
	//var remoteMethod:Dynamic;
	
	
	/**
	 * Provides values for undefined properties. When an undefined property of a Client object is referenced
	 * by Server-Side ActionScript code, the Client object is checked for a _resolve()  method. If the object
	 * has a _resolve() method, it is invoked and passed the name of the undefined property. The return value
	 * of the _resolve() method is the value of the undefined property. In this way, _resolve() can supply the
	 * values for undefined properties and make it appear as if they are defined.
	 * 
	 * @param	propname	A string indicating the name of an undefined property.
	 * @return		The value of the property specified by the propName  parameter.
	 */
	dynamic function __resolve(propname:String):Dynamic;
	
	/**
	 * Sets the maximum bandwidth for this client from client to server, server to client, or both. The default
	 * value for a connection is set for each application in the Client section of the Application.xml file. The
	 * value specified cannot exceed the bandwidth cap value specified in the Application.xml file. For more 
	 * information, see BandwidthCap in the Adobe Flash Media Server Configuration and Administration Guide.
	 * 
	 * @param	iServerToClient	The bandwidth from server to client, in bytes per second.
	 * 				Use 0 if you don’t want to change the current setting.
	 * @param	iClientToServer	the bandwidth from client to server, in bytes per second.
	 * 				Use 0 if you don’t want to change the current setting.
	 */
	function setBandwidthLimit(iServerToClient:Float, iClientToServer:Float):Void;
	
	
	public static inline function addProperty(name:String, prop:Dynamic):Void untyped
	{
		Reflect.setField(__js__("Client.prototype"), name, prop);
	}
}